#include <mysql/mysql.h>
#include <stdio.h>
#include <string.h>
int updatePwd(int userID, char *curPath)
{
	MYSQL *conn;
	MYSQL_RES *res;
	MYSQL_ROW row;
	char* server="localhost";
	char* user="root";
	char* password="1234";
	char* database="netdisk";
	char query[200] = {0}; 
	char buf[]="update user set pwd="; 

	sprintf(query,"%s'%s' where id=%d", buf, curPath, userID);
	/* puts(query); */

	int queryResult;

	conn=mysql_init(NULL);

	if(!mysql_real_connect(conn,server,user,password,database,0,NULL,0))
	{
		printf("Error connecting to database:%s\n",mysql_error(conn));
	}
    else
    {
		/* printf("Connected...\n"); */
	}

	queryResult = mysql_query(conn, query);
	if(queryResult)
	{
		printf("Error making query:%s\n",mysql_error(conn));
	}
    else
    {
        int ret = mysql_affected_rows(conn);
        if(ret)
        {
            /* printf("update pwd success\n"); */
        }
        else
        {
            printf("update fail, mysql_affected_rows:%d\n", ret);
        }
	}
	mysql_close(conn);
	return 0;
}
